<template>

	<!-- 开始节点 -->
	<start-node v-if="nodeConfig.type=='start'" v-model="nodeConfig"></start-node>

	<!-- 执行器 -->
	<action-node v-if="nodeConfig.type=='action'" v-model="nodeConfig"></action-node>

	<!-- 代码执行 -->
	<code-node v-if="nodeConfig.type=='code'" v-model="nodeConfig"></code-node>

	<!-- 条件分支 switch -->
	<switch-node v-if="nodeConfig.type=='switch'" v-model="nodeConfig">
		<template v-slot="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
		</template>
	</switch-node>

	<!-- 循环分支 while -->
	<batch-node v-if="nodeConfig.type=='batch'" v-model="nodeConfig">
		<template v-slot="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
		</template>
	</batch-node>

	<!-- 延迟执行 -->
	<delay-node v-if="nodeConfig.type=='delay'" v-model="nodeConfig"></delay-node>

	<!-- 批处理
	<batch-node v-if="nodeConfig.type=='batch'" v-model="nodeConfig"></batch-node>
 -->
	<!-- 终止 -->
	<stop-node v-if="nodeConfig.type=='stop'" v-model="nodeConfig"></stop-node>

	<!-- 返回 -->
	<return-node v-if="nodeConfig.type=='return'" v-model="nodeConfig"></return-node>

	<!--
	<branch v-if="nodeConfig.type=='branch'" v-model="nodeConfig">
		<template v-slot="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
		</template>
	</branch>
	-->

	<!-- 条件 -->
	<if-node v-if="nodeConfig.type=='if'" v-model="nodeConfig">
		<template v-slot="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
		</template>
	</if-node>

	<!-- 嵌套 -->
	<node-wrap v-if="nodeConfig.childNode" v-model="nodeConfig.childNode"></node-wrap>

</template>

<script>
	import branch from './nodes/branch'
	import trigger from './nodes/trigger'

	import switchNode from './nodes/switchNode'
	import actionNode from './nodes/actionNode'
	import stopNode from './nodes/stopNode'
	import ifNode from './nodes/ifNode'
	import delayNode from './nodes/delayNode'
	import batchNode from './nodes/batchNode'
	import returnNode from './nodes/returnNode'
	// import batchNode from './nodes/batchNode'
	import codeNode from './nodes/codeNode'
	import startNode from './nodes/startNode'

	export default {
		props: {
			modelValue: {
				type: Object,
				default: () => {}
			}
		},
		components: {
			branch,
			trigger,
			actionNode,
			stopNode,
			returnNode,
			ifNode,
			delayNode,
			batchNode,
			switchNode,
			// 吧Node,
			codeNode,
			startNode
		},
		data() {
			return {
				nodeConfig: {},
			}
		},
		watch: {
			modelValue(val) {
				this.nodeConfig = val
			},
			nodeConfig(val) {
				this.$emit("update:modelValue", val)
			}
		},
		mounted() {
			this.nodeConfig = this.modelValue
		},
		methods: {

		}
	}
</script>

<style>
</style>
